Import('env')

VariantDir('build-user', '.', duplicate = 0)
VariantDir('build-kernel', '.', duplicate = 0)

objects = Split('arc.c bplist.c dbuf.c dnode_sync.c dmu.c dmu_object.c dmu_objset.c dmu_send.c dmu_traverse.c dmu_tx.c dmu_zfetch.c dnode.c dsl_dataset.c dsl_deleg.c dsl_dir.c dsl_pool.c dsl_prop.c dsl_scan.c dsl_synctask.c fletcher.c flushwc.c gzip.c lzjb.c metaslab.c refcount.c rprwlock.c rrwlock.c sha256.c spa.c spa_config.c spa_errlog.c spa_history.c spa_misc.c space_map.c txg.c uberblock.c unique.c util.c vdev.c vdev_cache.c vdev_file.c vdev_label.c vdev_mirror.c vdev_missing.c vdev_queue.c vdev_raidz.c vdev_root.c zap.c zap_leaf.c zap_micro.c zfs_byteswap.c zfs_fm.c zfs_fuid.c zfs_znode.c zil.c zio.c zio_checksum.c zio_compress.c zio_inject.c kmem_asprintf.c ddt.c ddt_zap.c zle.c sa.c zfs_sa.c zfs_debug.c bpobj.c dsl_deadlist.c zrlock.c lzo.c bzip2.c lzma.c')

objects_user = ['build-user/' + o for o in objects] + Split('build-user/kernel.c build-user/taskq.c')
objects_kernel = ['build-kernel/' + o for o in objects]

cpppath_common = Split('#lib/libavl/include #lib/libnvpair/include #lib/libzfscommon/include #lib/libumem/include')
cpppath_user = cpppath_common + Split('./include #lib/libsolcompat/include')
cpppath_kernel = cpppath_common + ['#lib/libsolkerncompat/include']

ccflags_kernel = ['-D_KERNEL']

env.StaticLibrary('libzpool-user', objects_user, CPPPATH = env['CPPPATH'] + cpppath_user)
env.StaticLibrary('libzpool-kernel', objects_kernel, CPPPATH = env['CPPPATH'] + cpppath_kernel, CCFLAGS = env['CCFLAGS'] + ccflags_kernel)
